package com.yunhe.history.constant;

import com.yunhe.common.constant.MeasurementConsts;
import com.yunhe.common.util.StringUtil;

/**
 * InfluxDB常量类
 * @author liuronglei
 */
public class InfluxDBConsts {
    public static String RETENTION_POLICY = "autogen";
    public static String DATABASE = "sgool";

    public enum MEAS_COLUMN {
        FLAG("flag", "标记位"),
        R_TIME("time", "时间戳"),
        POINT_NUMBER("pid", "点号"),
        VAL("val", "点号值");
        private String value;
        private String title;
        MEAS_COLUMN(String value, String title) {
            this.value = value;
            this.title = title;
        }
        public String value() {
            return value;
        }
        public String title() {
            return title;
        }
    }

    public static String getTableName(String frequency) {
        if (StringUtil.isEmpty(frequency)) {
            return "data_meas_15m";
        } else if (MeasurementConsts.FREQUENCY.Original.value().equals(frequency)) {
            return "data_meas";
        } else if (MeasurementConsts.FREQUENCY.Minute15.value().equals(frequency)) {
            return "data_meas_15m";
        } else if (MeasurementConsts.FREQUENCY.Hour.value().equals(frequency)) {
            return "data_meas_1h";
        } else if (MeasurementConsts.FREQUENCY.Day.value().equals(frequency)) {
            return "data_meas_1d";
        } else {
            return "data_meas_15m";
        }
    }
}
